/**
 * @单位名称：飞羽个人
 * 	Copyright (c) 2017 All Rights Reserved.
 * @系统名称：测试
 * @工程名称：
 * @文件名称: 
 * @类路径: 
 */
package com.feiyu.controller;

import com.feiyu.bean.HouseUnit;
import com.feiyu.common.controller.BaseController;
import com.feiyu.common.util.CustomExcelUtil;
import com.feiyu.service.HouseUnitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

/**
 * 
 * 
 * @see
 * @author 	nanshouxiao
 * @date	2018-5-16 23:32:36
 * @version	V1.0.0
 */
@RestController
@RequestMapping("houseUnit")
public class HouseUnitController extends BaseController<HouseUnit> {
    @Autowired
    private HouseUnitService houseUnitService;

    private static final String[] titles = {""};

    @PostMapping("importHouseUnit")
    public List<HouseUnit> importHouseUnit(MultipartFile file, Integer projectId) {

        List<HouseUnit> houseProjectList = CustomExcelUtil.handleUnitExcel(file);
        houseProjectList.forEach(houseProject -> houseProject.setProjectId(projectId));
        houseUnitService.batchSaveEntity(houseProjectList);
        return houseProjectList;
    }

}
